import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86183
 * Date: 2024-03-31
 * Time: 15:00
 */
public class Demo4 {
    public static void main(String[] args) throws InterruptedException {
        Object object=new Object();
        Thread t1=new Thread(()->{
            synchronized (object){
                System.out.println("t1 等待之前");
                try {
                    object.wait();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println("t1 等待之后");
            }
        });
        Thread t2=new Thread(()->{
            Scanner scanner=new Scanner(System.in);
            synchronized (object){
                System.out.println("t2 通知之前");
                scanner.next();
                object.notify();
                System.out.println("t2 通知之后");
            }
        });

      //  Thread.sleep(1000);

        t2.start();
        t1.start();

    }
}
